package cn.iocoder.yudao.module.hs.dal.mysql.materiallog;

import cn.iocoder.yudao.framework.common.pojo.PageResult;
import cn.iocoder.yudao.framework.mybatis.core.mapper.BaseMapperX;
import cn.iocoder.yudao.framework.mybatis.core.query.LambdaQueryWrapperX;
import cn.iocoder.yudao.module.hs.controller.admin.materiallog.vo.MaterialLogPageReqVO;
import cn.iocoder.yudao.module.hs.dal.dataobject.materiallog.MaterialLogDO;
import org.apache.ibatis.annotations.Mapper;

/**
 * 物料日志 Mapper
 *
 * @author 航盛
 */
@Mapper
public interface MaterialLogMapper extends BaseMapperX<MaterialLogDO> {

    default PageResult<MaterialLogDO> selectPage(MaterialLogPageReqVO reqVO) {
        return selectPage(reqVO, new LambdaQueryWrapperX<MaterialLogDO>()
                .eqIfPresent(MaterialLogDO::getUserId, reqVO.getUserId())
                .eqIfPresent(MaterialLogDO::getMaterialId, reqVO.getMaterialId())
                .likeIfPresent(MaterialLogDO::getMaterialName, reqVO.getMaterialName())
                .likeIfPresent(MaterialLogDO::getMaterialCode, reqVO.getMaterialCode())
                .likeIfPresent(MaterialLogDO::getMaterialModeCode, reqVO.getMaterialModeCode())
                .likeIfPresent(MaterialLogDO::getMaterialBoxCode, reqVO.getMaterialBoxCode())
                .likeIfPresent(MaterialLogDO::getMaterialTrayCode, reqVO.getMaterialTrayCode())
                .likeIfPresent(MaterialLogDO::getWorkOrderNo, reqVO.getWorkOrderNo())
                .eqIfPresent(MaterialLogDO::getWarehouseId, reqVO.getWarehouseId())
                .eqIfPresent(MaterialLogDO::getOperateType, reqVO.getOperateType())
                .eqIfPresent(MaterialLogDO::getContent, reqVO.getContent())
                .betweenIfPresent(MaterialLogDO::getCreateTime, reqVO.getCreateTime())
                .orderByDesc(MaterialLogDO::getId));
    }

}
